package com.flurry.android;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.Looper;
import android.os.SystemClock;
import android.telephony.TelephonyManager;
import android.util.Log;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Method;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
import java.util.WeakHashMap;
import java.util.concurrent.atomic.AtomicInteger;

public final class FlurryAgent
  implements LocationListener
{
  static FlurryAgent an = new FlurryAgent();
  private static long ao = 10000L;
  private static boolean ap = true;
  private static Criteria aq = null;
  private static AtomicInteger as = new AtomicInteger(0);
  private static AtomicInteger at = new AtomicInteger(0);
  private String aA;
  private String aB;
  private String aC;
  private boolean aD = true;
  private List<am> aE;
  private LocationManager aF;
  private String aG;
  private Map<ReportedIdType, ByteBuffer> aH = new HashMap();
  private boolean aI;
  private long aJ;
  private List<am> aK = new ArrayList();
  private long aL;
  private long aM;
  private long aN;
  private String aO = "";
  private String aP = "";
  private byte aQ = -1;
  private String aR = "";
  private byte aS = -1;
  private Long aT;
  private int aU;
  private Location aV;
  private Map<String, k> aW = new HashMap();
  private List<fx> aX = new ArrayList();
  private boolean aY;
  private int aZ;
  private final Handler ar;
  private File au = null;
  private File av = null;
  private volatile boolean aw = false;
  private volatile boolean ax = false;
  private long ay;
  private Map<Context, Context> az = new WeakHashMap();
  private List<cb> ba = new ArrayList();
  private int bb;
  private Map<String, List<String>> bc;
  private Map<String, List<String>> bd;
  IFlurryAds be = o();
  private IAppCloudModule bf = n();
  ce bg = null;
  private fr bh = null;

  private FlurryAgent()
  {
    HandlerThread localHandlerThread = new HandlerThread("FlurryAgent");
    localHandlerThread.start();
    this.ar = new Handler(localHandlerThread.getLooper());
  }

  private void a(Context paramContext, String paramString)
  {
    while (true)
    {
      try
      {
        if (this.bh == null)
        {
          this.bh = new fr(paramContext.getApplicationContext(), this);
          this.bh.bv();
        }
        if ((this.aA != null) && (!this.aA.equals(paramString)))
          cy.d("FlurryAgent", "onStartSession called with different api keys: " + this.aA + " and " + paramString);
        if ((Context)this.az.put(paramContext, paramContext) != null)
          cy.g("FlurryAgent", "onStartSession called with duplicate context, use a specific Activity or Service as context instead of using a global context");
        FlurryAppCloud.G();
        a(new d(this, paramContext, paramString));
        if (this.aw)
          break label770;
        cy.c("FlurryAgent", "Initializing Flurry session");
        this.aA = paramString;
        this.au = paramContext.getFileStreamPath(".flurryagent." + Integer.toString(this.aA.hashCode(), 16));
        this.av = paramContext.getFileStreamPath(".flurryinstallreceiver.");
        ay.Y();
        Context localContext = paramContext.getApplicationContext();
        if (this.aC == null)
          this.aC = e(localContext);
        String str1 = localContext.getPackageName();
        if ((this.aB != null) && (!this.aB.equals(str1)))
          cy.d("FlurryAgent", "onStartSession called from different application packages: " + this.aB + " and " + str1);
        this.aB = str1;
        long l = SystemClock.elapsedRealtime();
        if (l - this.ay <= ao)
          break;
        cy.c("FlurryAgent", "New session");
        this.aL = System.currentTimeMillis();
        this.aM = l;
        this.aN = -1L;
        this.aR = "";
        this.aU = 0;
        this.aV = null;
        this.aP = TimeZone.getDefault().getID();
        this.aO = (Locale.getDefault().getLanguage() + "_" + Locale.getDefault().getCountry());
        this.aW = new HashMap();
        this.aX = new ArrayList();
        this.aY = true;
        this.ba = new ArrayList();
        this.aZ = 0;
        this.bb = 0;
        as.set(0);
        at.set(0);
        if (r())
          this.be.onStartNewSession(paramContext, this.aL, this.aM);
        a(new b(this, localContext, this.aD));
        if (!(paramContext instanceof Activity))
          break label765;
        Bundle localBundle = ((Activity)paramContext).getIntent().getExtras();
        if (localBundle == null)
          break label765;
        new StringBuilder().append("Launch Options Bundle is present ").append(localBundle.toString()).toString();
        this.bd = new HashMap();
        Iterator localIterator = localBundle.keySet().iterator();
        if (!localIterator.hasNext())
          break label765;
        String str2 = (String)localIterator.next();
        if (str2 == null)
          continue;
        Object localObject2 = localBundle.get(str2);
        if (localObject2 != null)
        {
          str3 = localObject2.toString();
          this.bd.put(str2, new ArrayList(Arrays.asList(new String[] { str3 })));
          new StringBuilder().append("Launch options Key: ").append(str2).append(". Its value: ").append(str3).toString();
          continue;
        }
      }
      finally
      {
      }
      String str3 = "null";
    }
    cy.c("FlurryAgent", "Continuing previous session");
    if (!this.aK.isEmpty())
      this.aK.remove(-1 + this.aK.size());
    if (r())
      this.be.onContinueSession(paramContext);
    label765: this.aw = true;
    label770:
  }

  private void a(Context paramContext, boolean paramBoolean)
  {
    try
    {
      FlurryAppCloud.H();
      if ((paramContext != null) && ((Context)this.az.remove(paramContext) == null))
        cy.g("FlurryAgent", "onEndSession called without context from corresponding onStartSession");
      if ((this.aw) && (r()))
        this.be.cleanUpSession(paramContext);
      if ((this.aw) && (this.az.isEmpty()))
      {
        cy.c("FlurryAgent", "Ending session");
        x();
        if (paramContext != null)
          break label240;
      }
      label240: Context localContext;
      for (Object localObject2 = null; ; localObject2 = localContext)
      {
        if (paramContext != null)
        {
          String str = ((Context)localObject2).getPackageName();
          if (!this.aB.equals(str))
            cy.d("FlurryAgent", "onEndSession called from different application package, expected: " + this.aB + " actual: " + str);
        }
        long l = SystemClock.elapsedRealtime();
        this.ay = l;
        this.aN = (l - this.aM);
        b(this.aN);
        if (id() == null)
          cy.d("FlurryAgent", "Not creating report because of bad Android ID or generated ID is null");
        a(new c(this, paramBoolean, (Context)localObject2));
        if (r())
          this.be.onEndSession(paramContext);
        this.aw = false;
        return;
        localContext = paramContext.getApplicationContext();
      }
    }
    finally
    {
    }
  }

  private void a(fp paramfp)
  {
    this.ar.post(paramfp);
  }

  private void a(String paramString1, String paramString2, String paramString3, Throwable paramThrowable)
  {
    label293: 
    while (true)
    {
      try
      {
        if (this.ba == null)
        {
          cy.d("FlurryAgent", "onError called before onStartSession.  Error: " + paramString1);
          return;
        }
        if ((paramString1 != null) && ("uncaught".equals(paramString1)))
        {
          i = 1;
          this.aU = (1 + this.aU);
          if (this.ba.size() >= 50)
            break label168;
          Long localLong2 = Long.valueOf(System.currentTimeMillis());
          cb localcb3 = new cb(at.incrementAndGet(), localLong2.longValue(), paramString1, paramString2, paramString3, paramThrowable);
          this.ba.add(localcb3);
          cy.c("FlurryAgent", "Error logged: " + localcb3.at());
          continue;
        }
      }
      finally
      {
      }
      int i = 0;
      continue;
      label168: if (i != 0);
      for (int j = 0; ; j++)
      {
        if (j >= this.ba.size())
          break label293;
        cb localcb1 = (cb)this.ba.get(j);
        if ((localcb1.at() != null) && (!"uncaught".equals(localcb1.at())))
        {
          Long localLong1 = Long.valueOf(System.currentTimeMillis());
          cb localcb2 = new cb(at.incrementAndGet(), localLong1.longValue(), paramString1, paramString2, paramString3, paramThrowable);
          this.ba.set(j, localcb2);
          break;
          cy.c("FlurryAgent", "Max errors logged. No more errors logged.");
          break;
        }
      }
    }
  }

  private void a(String paramString, Map<String, String> paramMap)
  {
    while (true)
    {
      fx localfx;
      HashMap localHashMap;
      try
      {
        Iterator localIterator = this.aX.iterator();
        int i;
        if (localIterator.hasNext())
        {
          localfx = (fx)localIterator.next();
          if (!localfx.K(paramString))
            continue;
          long l = SystemClock.elapsedRealtime() - this.aM;
          if ((paramMap != null) && (paramMap.size() > 0) && (this.aZ < 160000))
          {
            i = this.aZ - localfx.getBytes().length;
            localHashMap = new HashMap(localfx.getParameters());
            localfx.d(paramMap);
            if (i + localfx.getBytes().length > 160000)
              break label212;
            if (localfx.getParameters().size() <= 10)
              continue;
            cy.g("FlurryAgent", "MaxEventParams exceeded on endEvent: " + localfx.getParameters().size());
            localfx.e(localHashMap);
          }
          localfx.h(l);
        }
        return;
        this.aZ = (i + localfx.getBytes().length);
        continue;
      }
      finally
      {
      }
      label212: localfx.e(localHashMap);
      this.aY = false;
      this.aZ = 160000;
      cy.g("FlurryAgent", "Event Log size exceeded. No more event details logged.");
    }
  }

  private void a(String paramString, Map<String, String> paramMap, boolean paramBoolean)
  {
    while (true)
    {
      long l;
      String str;
      k localk1;
      Object localObject2;
      try
      {
        if (this.aX == null)
        {
          cy.d("FlurryAgent", "onEvent called before onStartSession.  Event: " + paramString);
          return;
        }
        l = SystemClock.elapsedRealtime() - this.aM;
        str = fl.sanitize(paramString);
        if (str.length() == 0)
          continue;
        localk1 = (k)this.aW.get(str);
        if (localk1 != null)
          break label273;
        if (this.aW.size() < 100)
        {
          k localk2 = new k();
          localk2.value = 1;
          this.aW.put(str, localk2);
          cy.c("FlurryAgent", "Event count incremented: " + str);
          if ((!ap) || (this.aX.size() >= 1000) || (this.aZ >= 160000))
            break label380;
          if (paramMap != null)
            break label388;
          localObject2 = Collections.emptyMap();
          if (((Map)localObject2).size() <= 10)
            break label288;
          cy.g("FlurryAgent", "MaxEventParams exceeded: " + ((Map)localObject2).size());
          continue;
        }
      }
      finally
      {
      }
      cy.g("FlurryAgent", "Too many different events. Event not counted: " + str);
      continue;
      label273: localk1.value = (1 + localk1.value);
      continue;
      label288: fx localfx = new fx(as.incrementAndGet(), str, (Map)localObject2, l, paramBoolean);
      if (localfx.getBytes().length + this.aZ <= 160000)
      {
        this.aX.add(localfx);
        this.aZ += localfx.getBytes().length;
      }
      else
      {
        this.aZ = 160000;
        this.aY = false;
        cy.g("FlurryAgent", "Event Log size exceeded. No more event details logged.");
        continue;
        label380: this.aY = false;
        continue;
        label388: localObject2 = paramMap;
      }
    }
  }

  private void b(long paramLong)
  {
    Iterator localIterator = this.aX.iterator();
    while (localIterator.hasNext())
    {
      fx localfx = (fx)localIterator.next();
      if ((localfx.bC()) && (!localfx.isFinished()))
        localfx.h(paramLong);
    }
  }

  // ERROR //
  private void d(Context paramContext)
  {
    // Byte code:
    //   0: aload_0
    //   1: monitorenter
    //   2: aload_0
    //   3: aload_1
    //   4: invokestatic 642	com/flurry/android/o:a	(Landroid/content/Context;)Ljava/lang/String;
    //   7: putfield 644	com/flurry/android/FlurryAgent:aG	Ljava/lang/String;
    //   10: aload_0
    //   11: getfield 106	com/flurry/android/FlurryAgent:au	Ljava/io/File;
    //   14: invokevirtual 649	java/io/File:exists	()Z
    //   17: ifeq +274 -> 291
    //   20: ldc 167
    //   22: new 212	java/lang/StringBuilder
    //   25: dup
    //   26: invokespecial 213	java/lang/StringBuilder:<init>	()V
    //   29: ldc_w 651
    //   32: invokevirtual 219	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   35: aload_0
    //   36: getfield 106	com/flurry/android/FlurryAgent:au	Ljava/io/File;
    //   39: invokevirtual 654	java/io/File:getAbsolutePath	()Ljava/lang/String;
    //   42: invokevirtual 219	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   45: invokevirtual 225	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   48: invokestatic 656	com/flurry/android/cy:e	(Ljava/lang/String;Ljava/lang/String;)V
    //   51: new 658	java/io/DataInputStream
    //   54: dup
    //   55: new 660	java/io/FileInputStream
    //   58: dup
    //   59: aload_0
    //   60: getfield 106	com/flurry/android/FlurryAgent:au	Ljava/io/File;
    //   63: invokespecial 663	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   66: invokespecial 666	java/io/DataInputStream:<init>	(Ljava/io/InputStream;)V
    //   69: astore_3
    //   70: new 668	com/flurry/android/gr
    //   73: dup
    //   74: invokespecial 669	com/flurry/android/gr:<init>	()V
    //   77: astore 4
    //   79: aload_0
    //   80: aload 4
    //   82: aload_3
    //   83: aload_0
    //   84: getfield 204	com/flurry/android/FlurryAgent:aA	Ljava/lang/String;
    //   87: invokevirtual 672	com/flurry/android/gr:a	(Ljava/io/DataInputStream;Ljava/lang/String;)Z
    //   90: putfield 112	com/flurry/android/FlurryAgent:ax	Z
    //   93: aload_0
    //   94: getfield 112	com/flurry/android/FlurryAgent:ax	Z
    //   97: ifeq +30 -> 127
    //   100: aload_0
    //   101: aload 4
    //   103: invokevirtual 675	com/flurry/android/gr:bR	()J
    //   106: putfield 677	com/flurry/android/FlurryAgent:aJ	J
    //   109: aload_0
    //   110: aload 4
    //   112: invokevirtual 680	com/flurry/android/gr:bP	()Z
    //   115: putfield 682	com/flurry/android/FlurryAgent:aI	Z
    //   118: aload_0
    //   119: aload 4
    //   121: invokevirtual 686	com/flurry/android/gr:bQ	()Ljava/util/List;
    //   124: putfield 129	com/flurry/android/FlurryAgent:aK	Ljava/util/List;
    //   127: aload_3
    //   128: invokestatic 689	com/flurry/android/fl:a	(Ljava/io/Closeable;)V
    //   131: aload_0
    //   132: getfield 112	com/flurry/android/FlurryAgent:ax	Z
    //   135: ifne +21 -> 156
    //   138: aload_0
    //   139: getfield 106	com/flurry/android/FlurryAgent:au	Ljava/io/File;
    //   142: invokevirtual 692	java/io/File:delete	()Z
    //   145: ifeq +121 -> 266
    //   148: ldc 167
    //   150: ldc_w 694
    //   153: invokestatic 260	com/flurry/android/cy:c	(Ljava/lang/String;Ljava/lang/String;)V
    //   156: aload_0
    //   157: getfield 112	com/flurry/android/FlurryAgent:ax	Z
    //   160: ifne +21 -> 181
    //   163: aload_0
    //   164: iconst_0
    //   165: putfield 682	com/flurry/android/FlurryAgent:aI	Z
    //   168: aload_0
    //   169: aload_0
    //   170: getfield 312	com/flurry/android/FlurryAgent:aL	J
    //   173: putfield 677	com/flurry/android/FlurryAgent:aJ	J
    //   176: aload_0
    //   177: iconst_1
    //   178: putfield 112	com/flurry/android/FlurryAgent:ax	Z
    //   181: invokestatic 357	com/flurry/android/FlurryAgent:r	()Z
    //   184: ifeq +16 -> 200
    //   187: aload_0
    //   188: getfield 153	com/flurry/android/FlurryAgent:be	Lcom/flurry/android/IFlurryAds;
    //   191: aload_0
    //   192: getfield 124	com/flurry/android/FlurryAgent:aH	Ljava/util/Map;
    //   195: invokeinterface 697 2 0
    //   200: aload_0
    //   201: new 699	com/flurry/android/ar
    //   204: dup
    //   205: aload_0
    //   206: getfield 108	com/flurry/android/FlurryAgent:av	Ljava/io/File;
    //   209: invokespecial 700	com/flurry/android/ar:<init>	(Ljava/io/File;)V
    //   212: invokevirtual 703	com/flurry/android/ar:W	()Ljava/util/Map;
    //   215: putfield 705	com/flurry/android/FlurryAgent:bc	Ljava/util/Map;
    //   218: aload_0
    //   219: monitorexit
    //   220: return
    //   221: astore 8
    //   223: aload 8
    //   225: invokevirtual 708	java/io/IOException:printStackTrace	()V
    //   228: goto -101 -> 127
    //   231: astore 6
    //   233: ldc 167
    //   235: ldc_w 710
    //   238: aload 6
    //   240: invokestatic 514	com/flurry/android/cy:b	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   243: aload_3
    //   244: invokestatic 689	com/flurry/android/fl:a	(Ljava/io/Closeable;)V
    //   247: goto -116 -> 131
    //   250: astore_2
    //   251: aload_0
    //   252: monitorexit
    //   253: aload_2
    //   254: athrow
    //   255: astore 5
    //   257: aconst_null
    //   258: astore_3
    //   259: aload_3
    //   260: invokestatic 689	com/flurry/android/fl:a	(Ljava/io/Closeable;)V
    //   263: aload 5
    //   265: athrow
    //   266: ldc 167
    //   268: ldc_w 712
    //   271: invokestatic 231	com/flurry/android/cy:d	(Ljava/lang/String;Ljava/lang/String;)V
    //   274: goto -118 -> 156
    //   277: astore 7
    //   279: ldc 167
    //   281: ldc 131
    //   283: aload 7
    //   285: invokestatic 514	com/flurry/android/cy:b	(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   288: goto -132 -> 156
    //   291: ldc 167
    //   293: ldc_w 714
    //   296: invokestatic 656	com/flurry/android/cy:e	(Ljava/lang/String;Ljava/lang/String;)V
    //   299: goto -143 -> 156
    //   302: astore 5
    //   304: goto -45 -> 259
    //   307: astore 6
    //   309: aconst_null
    //   310: astore_3
    //   311: goto -78 -> 233
    //
    // Exception table:
    //   from	to	target	type
    //   70	127	221	java/io/IOException
    //   70	127	231	java/lang/Throwable
    //   223	228	231	java/lang/Throwable
    //   2	51	250	finally
    //   127	131	250	finally
    //   131	156	250	finally
    //   156	181	250	finally
    //   181	200	250	finally
    //   200	218	250	finally
    //   243	247	250	finally
    //   259	266	250	finally
    //   266	274	250	finally
    //   279	288	250	finally
    //   291	299	250	finally
    //   51	70	255	finally
    //   131	156	277	java/lang/Throwable
    //   266	274	277	java/lang/Throwable
    //   70	127	302	finally
    //   223	228	302	finally
    //   233	243	302	finally
    //   51	70	307	java/lang/Throwable
  }

  private static String e(Context paramContext)
  {
    try
    {
      PackageInfo localPackageInfo = paramContext.getPackageManager().getPackageInfo(paramContext.getPackageName(), 0);
      if (localPackageInfo.versionName != null)
        return localPackageInfo.versionName;
      if (localPackageInfo.versionCode != 0)
      {
        String str = Integer.toString(localPackageInfo.versionCode);
        return str;
      }
    }
    catch (Throwable localThrowable)
    {
      cy.b("FlurryAgent", "", localThrowable);
    }
    return "Unknown";
  }

  public static void endTimedEvent(String paramString)
  {
    if (paramString == null)
    {
      cy.d("FlurryAgent", "String eventId passed to endTimedEvent was null.");
      return;
    }
    try
    {
      an.a(paramString, null);
      return;
    }
    catch (Throwable localThrowable)
    {
      cy.b("FlurryAgent", "Failed to signify the end of event: " + paramString, localThrowable);
    }
  }

  public static void endTimedEvent(String paramString, Map<String, String> paramMap)
  {
    if (paramString == null)
    {
      cy.d("FlurryAgent", "String eventId passed to endTimedEvent was null.");
      return;
    }
    if (paramMap == null)
    {
      cy.d("FlurryAgent", "String eventId passed to endTimedEvent was null.");
      return;
    }
    try
    {
      an.a(paramString, paramMap);
      return;
    }
    catch (Throwable localThrowable)
    {
      cy.b("FlurryAgent", "Failed to signify the end of event: " + paramString, localThrowable);
    }
  }

  private Location f(Context paramContext)
  {
    if ((paramContext.checkCallingOrSelfPermission("android.permission.ACCESS_FINE_LOCATION") == 0) || (paramContext.checkCallingOrSelfPermission("android.permission.ACCESS_COARSE_LOCATION") == 0))
    {
      LocationManager localLocationManager = (LocationManager)paramContext.getSystemService("location");
      try
      {
        if (this.aF == null)
          this.aF = localLocationManager;
        while (true)
        {
          Criteria localCriteria = aq;
          if (localCriteria == null)
            localCriteria = new Criteria();
          String str = localLocationManager.getBestProvider(localCriteria, true);
          if (str == null)
            break;
          localLocationManager.requestLocationUpdates(str, 0L, 0.0F, this, Looper.getMainLooper());
          return localLocationManager.getLastKnownLocation(str);
          localLocationManager = this.aF;
        }
      }
      finally
      {
      }
    }
    return null;
  }

  public static int getAgentVersion()
  {
    return 150;
  }

  static String getLocale()
  {
    return an.aO;
  }

  static Location getLocation()
  {
    return an.aV;
  }

  public static String getPhoneId()
  {
    return an.id();
  }

  public static boolean getUseHttps()
  {
    return ce.getUseHttps();
  }

  private String id()
  {
    try
    {
      String str = this.aG;
      return str;
    }
    finally
    {
      localObject = finally;
      throw localObject;
    }
  }

  public static void logEvent(String paramString)
  {
    if (paramString == null)
    {
      cy.d("FlurryAgent", "String eventId passed to logEvent was null.");
      return;
    }
    try
    {
      an.a(paramString, null, false);
      return;
    }
    catch (Throwable localThrowable)
    {
      cy.b("FlurryAgent", "Failed to log event: " + paramString, localThrowable);
    }
  }

  public static void logEvent(String paramString, Map<String, String> paramMap)
  {
    if (paramString == null)
    {
      cy.d("FlurryAgent", "String eventId passed to logEvent was null.");
      return;
    }
    if (paramMap == null)
    {
      cy.d("FlurryAgent", "String parameters passed to logEvent was null.");
      return;
    }
    try
    {
      an.a(paramString, paramMap, false);
      return;
    }
    catch (Throwable localThrowable)
    {
      cy.b("FlurryAgent", "Failed to log event: " + paramString, localThrowable);
    }
  }

  public static void logEvent(String paramString, Map<String, String> paramMap, boolean paramBoolean)
  {
    if (paramString == null)
    {
      cy.d("FlurryAgent", "String eventId passed to logEvent was null.");
      return;
    }
    if (paramMap == null)
    {
      cy.d("FlurryAgent", "String parameters passed to logEvent was null.");
      return;
    }
    try
    {
      an.a(paramString, paramMap, paramBoolean);
      return;
    }
    catch (Throwable localThrowable)
    {
      cy.b("FlurryAgent", "Failed to log event: " + paramString, localThrowable);
    }
  }

  public static void logEvent(String paramString, boolean paramBoolean)
  {
    if (paramString == null)
    {
      cy.d("FlurryAgent", "String eventId passed to logEvent was null.");
      return;
    }
    try
    {
      an.a(paramString, null, paramBoolean);
      return;
    }
    catch (Throwable localThrowable)
    {
      cy.b("FlurryAgent", "Failed to log event: " + paramString, localThrowable);
    }
  }

  private static IAppCloudModule n()
  {
    if (!q())
      return null;
    try
    {
      IAppCloudModule localIAppCloudModule = (IAppCloudModule)Class.forName("com.flurry.android.es").getDeclaredMethod("getInstance", new Class[0]).invoke(null, new Object[0]);
      return localIAppCloudModule;
    }
    catch (Exception localException)
    {
      localException.toString();
    }
    return null;
  }

  private static IFlurryAds o()
  {
    if (!r())
      return null;
    try
    {
      IFlurryAds localIFlurryAds = (IFlurryAds)Class.forName("com.flurry.android.FlurryAds").getDeclaredMethod("getInstance", new Class[0]).invoke(null, new Object[0]);
      return localIFlurryAds;
    }
    catch (Exception localException)
    {
      localException.toString();
    }
    return null;
  }

  public static void onEndSession(Context paramContext)
  {
    if (paramContext == null)
      throw new NullPointerException("Null context");
    try
    {
      an.a(paramContext, false);
      return;
    }
    catch (Throwable localThrowable)
    {
      cy.b("FlurryAgent", "", localThrowable);
    }
  }

  public static void onError(String paramString1, String paramString2, String paramString3)
  {
    if (paramString1 == null)
    {
      cy.d("FlurryAgent", "String errorId passed to onError was null.");
      return;
    }
    if (paramString2 == null)
    {
      cy.d("FlurryAgent", "String message passed to onError was null.");
      return;
    }
    if (paramString3 == null)
    {
      cy.d("FlurryAgent", "String errorClass passed to onError was null.");
      return;
    }
    while (true)
    {
      StackTraceElement[] arrayOfStackTraceElement1;
      try
      {
        arrayOfStackTraceElement1 = Thread.currentThread().getStackTrace();
        if ((arrayOfStackTraceElement1 != null) && (arrayOfStackTraceElement1.length > 2))
        {
          arrayOfStackTraceElement2 = new StackTraceElement[-2 + arrayOfStackTraceElement1.length];
          System.arraycopy(arrayOfStackTraceElement1, 2, arrayOfStackTraceElement2, 0, arrayOfStackTraceElement2.length);
          Throwable localThrowable2 = new Throwable(paramString2);
          localThrowable2.setStackTrace(arrayOfStackTraceElement2);
          an.a(paramString1, paramString2, paramString3, localThrowable2);
          return;
        }
      }
      catch (Throwable localThrowable1)
      {
        cy.b("FlurryAgent", "", localThrowable1);
        return;
      }
      StackTraceElement[] arrayOfStackTraceElement2 = arrayOfStackTraceElement1;
    }
  }

  public static void onError(String paramString1, String paramString2, Throwable paramThrowable)
  {
    if (paramString1 == null)
    {
      cy.d("FlurryAgent", "String errorId passed to onError was null.");
      return;
    }
    if (paramString2 == null)
    {
      cy.d("FlurryAgent", "String message passed to onError was null.");
      return;
    }
    if (paramThrowable == null)
    {
      cy.d("FlurryAgent", "Throwable passed to onError was null.");
      return;
    }
    try
    {
      an.a(paramString1, paramString2, paramThrowable.getClass().getName(), paramThrowable);
      return;
    }
    catch (Throwable localThrowable)
    {
      cy.b("FlurryAgent", "", localThrowable);
    }
  }

  public static void onEvent(String paramString)
  {
    if (paramString == null)
    {
      cy.d("FlurryAgent", "String eventId passed to onEvent was null.");
      return;
    }
    try
    {
      an.a(paramString, null, false);
      return;
    }
    catch (Throwable localThrowable)
    {
      cy.b("FlurryAgent", "", localThrowable);
    }
  }

  public static void onEvent(String paramString, Map<String, String> paramMap)
  {
    if (paramString == null)
    {
      cy.d("FlurryAgent", "String eventId passed to onEvent was null.");
      return;
    }
    if (paramMap == null)
    {
      cy.d("FlurryAgent", "Parameters Map passed to onEvent was null.");
      return;
    }
    try
    {
      an.a(paramString, paramMap, false);
      return;
    }
    catch (Throwable localThrowable)
    {
      cy.b("FlurryAgent", "", localThrowable);
    }
  }

  public static void onPageView()
  {
    try
    {
      an.u();
      return;
    }
    catch (Throwable localThrowable)
    {
      cy.b("FlurryAgent", "", localThrowable);
    }
  }

  public static void onStartSession(Context paramContext, String paramString)
  {
    if (paramContext == null)
      throw new NullPointerException("Null context");
    if ((paramString == null) || (paramString.length() == 0))
      throw new IllegalArgumentException("Api key not specified");
    try
    {
      an.a(paramContext, paramString);
      return;
    }
    catch (Throwable localThrowable)
    {
      cy.b("FlurryAgent", "", localThrowable);
    }
  }

  static boolean p()
  {
    return (an.ax) && (an.aw);
  }

  static boolean q()
  {
    if (n.SDK_INT <= 8);
    while (true)
    {
      return false;
      if ((an != null) && (an.bf != null))
        return true;
      try
      {
        Class localClass = Class.forName("com.flurry.android.es");
        if (localClass != null)
          return true;
      }
      catch (Throwable localThrowable)
      {
        new StringBuilder().append("isAppCloudEnabled caught:").append(localThrowable.toString()).toString();
      }
    }
    return false;
  }

  static boolean r()
  {
    if (n.SDK_INT <= 8);
    while (true)
    {
      return false;
      if ((an != null) && (an.be != null))
        return true;
      try
      {
        Class localClass = Class.forName("com.flurry.android.FlurryAds");
        if (localClass != null)
          return true;
      }
      catch (Throwable localThrowable)
      {
        new StringBuilder().append("isAppSpotEnabled caught:").append(localThrowable.toString()).toString();
      }
    }
    return false;
  }

  public static void setAge(int paramInt)
  {
    if ((paramInt > 0) && (paramInt < 110))
    {
      Date localDate = new Date(new Date(System.currentTimeMillis() - 31449600000L * paramInt).getYear(), 1, 1);
      an.aT = Long.valueOf(localDate.getTime());
    }
  }

  public static void setCaptureUncaughtExceptions(boolean paramBoolean)
  {
    ay.Y().setEnabled(paramBoolean);
  }

  public static void setContinueSessionMillis(long paramLong)
  {
    if (paramLong < 5000L)
    {
      cy.d("FlurryAgent", "Invalid time set for session resumption: " + paramLong);
      return;
    }
    synchronized (an)
    {
      ao = paramLong;
      return;
    }
  }

  public static void setGender(byte paramByte)
  {
    switch (paramByte)
    {
    default:
      an.aS = -1;
      return;
    case 0:
    case 1:
    }
    an.aS = paramByte;
  }

  public static void setLocationCriteria(Criteria paramCriteria)
  {
    synchronized (an)
    {
      aq = paramCriteria;
      return;
    }
  }

  public static void setLogEnabled(boolean paramBoolean)
  {
    FlurryAgent localFlurryAgent = an;
    if (paramBoolean);
    try
    {
      cy.aE();
      while (true)
      {
        return;
        cy.aD();
      }
    }
    finally
    {
    }
  }

  public static void setLogEvents(boolean paramBoolean)
  {
    synchronized (an)
    {
      ap = paramBoolean;
      return;
    }
  }

  public static void setLogLevel(int paramInt)
  {
    synchronized (an)
    {
      cy.setLogLevel(paramInt);
      return;
    }
  }

  public static void setReportLocation(boolean paramBoolean)
  {
    synchronized (an)
    {
      an.aD = paramBoolean;
      return;
    }
  }

  public static void setReportUrl(String paramString)
  {
    ce.setReportUrl(paramString);
  }

  public static void setUseHttps(boolean paramBoolean)
  {
    ce.setUseHttps(paramBoolean);
  }

  public static void setUserId(String paramString)
  {
    if (paramString == null)
    {
      cy.d("FlurryAgent", "String userId passed to setUserId was null.");
      return;
    }
    synchronized (an)
    {
      an.aR = fl.sanitize(paramString);
      return;
    }
  }

  public static void setVersionName(String paramString)
  {
    if (paramString == null)
    {
      cy.d("FlurryAgent", "String versionName passed to setVersionName was null.");
      return;
    }
    synchronized (an)
    {
      an.aC = paramString;
      return;
    }
  }

  private am t()
  {
    try
    {
      eb localeb = new eb();
      localeb.setVersion(this.aC);
      localeb.d(this.aL);
      localeb.e(this.aN);
      localeb.f(0L);
      localeb.y(this.aO);
      localeb.setTimeZone(this.aP);
      localeb.b(this.aQ);
      String str;
      if (this.aR == null)
        str = "";
      while (true)
      {
        localeb.setUserId(str);
        localeb.a(this.aV);
        localeb.c(this.bb);
        localeb.setGender(this.aS);
        localeb.c(this.aT);
        localeb.e(this.aX);
        localeb.b(this.aW);
        localeb.f(this.ba);
        localeb.d(this.aU);
        localeb.a(this.aY);
        try
        {
          localam = new am(localeb);
          return localam;
          str = this.aR;
        }
        catch (IOException localIOException)
        {
          while (true)
          {
            localIOException.printStackTrace();
            am localam = null;
          }
        }
      }
    }
    finally
    {
    }
  }

  private void u()
  {
    try
    {
      this.bb = (1 + this.bb);
      return;
    }
    finally
    {
      localObject = finally;
      throw localObject;
    }
  }

  private void v()
  {
    while (true)
    {
      try
      {
        cy.c("FlurryAgent", "generating agent report");
        cn localcn = new cn(this.aA, this.aC, id(), this.aJ, this.aL, this.aK, this.av, this.aH, this.bc, this.bd);
        this.aE = new ArrayList(this.aK);
        if (localcn.N() != null)
        {
          cy.c("FlurryAgent", "generated report of size " + localcn.N().length + " with " + this.aK.size() + " reports.");
          this.bg.a(localcn.N());
          this.aI = true;
          this.aK.removeAll(this.aE);
          this.aE = null;
          StringBuilder localStringBuilder = new StringBuilder().append("Done sending ");
          if (this.aw)
          {
            str = "initial ";
            cy.c("FlurryAgent", str + "agent report");
            w();
          }
        }
        else
        {
          cy.c("FlurryAgent", "Error generating report");
          return;
        }
      }
      catch (Throwable localThrowable)
      {
        cy.b("FlurryAgent", "", localThrowable);
        return;
      }
      String str = "";
    }
  }

  // ERROR //
  private void w()
  {
    // Byte code:
    //   0: aload_0
    //   1: monitorenter
    //   2: aload_0
    //   3: getfield 106	com/flurry/android/FlurryAgent:au	Ljava/io/File;
    //   6: invokestatic 1056	com/flurry/android/an:a	(Ljava/io/File;)Z
    //   9: ifne +14 -> 23
    //   12: ldc 167
    //   14: ldc_w 1058
    //   17: invokestatic 231	com/flurry/android/cy:d	(Ljava/lang/String;Ljava/lang/String;)V
    //   20: aload_0
    //   21: monitorexit
    //   22: return
    //   23: new 1060	java/io/DataOutputStream
    //   26: dup
    //   27: new 1062	java/io/FileOutputStream
    //   30: dup
    //   31: aload_0
    //   32: getfield 106	com/flurry/android/FlurryAgent:au	Ljava/io/File;
    //   35: invokespecial 1063	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   38: invokespecial 1066	java/io/DataOutputStream:<init>	(Ljava/io/OutputStream;)V
    //   41: astore_2
    //   42: new 668	com/flurry/android/gr
    //   45: dup
    //   46: invokespecial 669	com/flurry/android/gr:<init>	()V
    //   49: astore_3
    //   50: aload_3
    //   51: aload_0
    //   52: getfield 677	com/flurry/android/FlurryAgent:aJ	J
    //   55: invokevirtual 1069	com/flurry/android/gr:i	(J)V
    //   58: aload_3
    //   59: aload_0
    //   60: getfield 682	com/flurry/android/FlurryAgent:aI	Z
    //   63: invokevirtual 1071	com/flurry/android/gr:b	(Z)V
    //   66: aload_3
    //   67: aload_0
    //   68: getfield 129	com/flurry/android/FlurryAgent:aK	Ljava/util/List;
    //   71: invokevirtual 1074	com/flurry/android/gr:k	(Ljava/util/List;)V
    //   74: aload_3
    //   75: aload_2
    //   76: aload_0
    //   77: getfield 204	com/flurry/android/FlurryAgent:aA	Ljava/lang/String;
    //   80: aload_0
    //   81: invokespecial 473	com/flurry/android/FlurryAgent:id	()Ljava/lang/String;
    //   84: invokevirtual 1077	com/flurry/android/gr:a	(Ljava/io/DataOutputStream;Ljava/lang/String;Ljava/lang/String;)V
    //   87: goto -67 -> 20
    //   90: astore 5
    //   92: aload 5
    //   94: invokevirtual 1078	java/io/FileNotFoundException:printStackTrace	()V
    //   97: goto -77 -> 20
    //   100: astore_1
    //   101: aload_0
    //   102: monitorexit
    //   103: aload_1
    //   104: athrow
    //   105: astore 4
    //   107: aload 4
    //   109: invokevirtual 708	java/io/IOException:printStackTrace	()V
    //   112: goto -92 -> 20
    //
    // Exception table:
    //   from	to	target	type
    //   23	87	90	java/io/FileNotFoundException
    //   2	20	100	finally
    //   23	87	100	finally
    //   92	97	100	finally
    //   107	112	100	finally
    //   23	87	105	java/io/IOException
  }

  private void x()
  {
    try
    {
      if (this.aF != null)
        this.aF.removeUpdates(this);
      return;
    }
    finally
    {
      localObject = finally;
      throw localObject;
    }
  }

  static String y()
  {
    return an.aA;
  }

  static String z()
  {
    return an.aP;
  }

  final void a(Throwable paramThrowable)
  {
    paramThrowable.printStackTrace();
    String str = "";
    StackTraceElement[] arrayOfStackTraceElement = paramThrowable.getStackTrace();
    if ((arrayOfStackTraceElement != null) && (arrayOfStackTraceElement.length > 0))
    {
      StringBuilder localStringBuilder = new StringBuilder();
      if (paramThrowable.getMessage() != null)
        localStringBuilder.append(" (" + paramThrowable.getMessage() + ")\n");
      str = localStringBuilder.toString();
    }
    while (true)
    {
      onError("uncaught", str, paramThrowable);
      this.az.clear();
      a(null, true);
      return;
      if (paramThrowable.getMessage() != null)
        str = paramThrowable.getMessage();
    }
  }

  protected final byte[] fetchHashedImei(Context paramContext)
  {
    String str;
    if (paramContext.checkCallingOrSelfPermission("android.permission.READ_PHONE_STATE") == 0)
    {
      TelephonyManager localTelephonyManager = (TelephonyManager)paramContext.getSystemService("phone");
      if (localTelephonyManager != null)
      {
        str = localTelephonyManager.getDeviceId();
        if ((str == null) || (str.trim().length() <= 0));
      }
    }
    try
    {
      byte[] arrayOfByte = fl.F(str);
      if ((arrayOfByte != null) && (arrayOfByte.length == 20))
        return arrayOfByte;
      cy.d("FlurryAgent", "sha1 is not 20 bytes long: " + Arrays.toString(arrayOfByte));
      label95: return null;
    }
    catch (Exception localException)
    {
      break label95;
    }
  }

  public final boolean getNetworkStatus()
  {
    if (this.bh != null)
      return this.bh.bu();
    return true;
  }

  public final void onLocationChanged(Location paramLocation)
  {
    try
    {
      this.aV = paramLocation;
      x();
      return;
    }
    catch (Throwable localThrowable)
    {
      while (true)
        cy.b("FlurryAgent", "", localThrowable);
    }
    finally
    {
    }
  }

  public final void onNetworkStateChanged(boolean paramBoolean)
  {
    Log.e("myNetworkListener", "onNetworkStateChanged = " + paramBoolean);
    if (an == null);
    while (an.bg == null)
      return;
    an.a(new f(paramBoolean));
  }

  public final void onProviderDisabled(String paramString)
  {
  }

  public final void onProviderEnabled(String paramString)
  {
  }

  public final void onStatusChanged(String paramString, int paramInt, Bundle paramBundle)
  {
  }

  final ce s()
  {
    return this.bg;
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.flurry.android.FlurryAgent
 * JD-Core Version:    0.6.2
 */